const datas = (state=[],action)=>{
    switch(action.type){
        case 'ADD':
            return [
                ...state,
                {
                    id:action.id,
                    text:action.text,
                    completed: false
                }
            ]
        case 'TOGGLE':
            return state.map(data =>(data.id === action.id)?{...data,completed:!data.completed}:data);
        default:
            return state;
    }
}
export default  datas;